package com.heima.article.controller.v1;

import com.heima.article.service.ArticleService;
import com.heima.common.constants.ArticleConstants;
import com.heima.model.common.article.dto.ArticleDto;
import com.heima.model.common.article.dto.ArticleHomeDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/article")
public class ArticleHomeController {
    @Autowired
    private ArticleService articleService;
    /**
     * 加载首页
     * @return
     */
    @PostMapping("/load")
    public ResponseResult ArticleLoadController(@RequestBody ArticleHomeDto dto){
        ResponseResult responseResult = articleService.selectApArticle(dto, ArticleConstants.LOADTYPE_LOAD_MORE);
        return responseResult;
    }
    /**
     * 加载更多
     * @return
     */
    @PostMapping("/loadmore")
    public ResponseResult ArticleLoadmoreController(@RequestBody ArticleHomeDto dto){
        ResponseResult responseResult = articleService.selectApArticle(dto, ArticleConstants.LOADTYPE_LOAD_MORE);
        return responseResult;
    }
    /**
     * 加载更新
     * @return
     */
    @PostMapping("/loadnew")
    public ResponseResult ArticleLoadnewController(@RequestBody ArticleHomeDto dto){
        ResponseResult responseResult = articleService.selectApArticle(dto, ArticleConstants.LOADTYPE_LOAD_MORE);
        return responseResult;
    }

}
